package com.json;

import com.alibaba.fastjson.JSONObject;

import java.util.List;

public class JsonUtil {

    public static <T> T parse(String json, Class<T> aClass){
        T result = JSONObject.parseObject(json, aClass);
        return result;
    }

    public static <T> List<T> parseList(String json, Class<T> aClass){
        List<T> result = JSONObject.parseArray(json, aClass);
        return result;
    }

    public static <T> String toJson(T data){
        String result = JSONObject.toJSONString(data);
        return result;
    }

    public static <T> String toJson(List<T> data) {
        String result = JSONObject.toJSONString(data);
        return result;
    }

}
